package edu.uta.ui;

import edu.uta.ui.R;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

public class ZipCode2 extends Activity
{
	/**
	 * @uml.property  name="text"
	 * @uml.associationEnd  
	 */
	private EditText text;
	/**
	 * @uml.property  name="submitButton"
	 * @uml.associationEnd  
	 */
	private Button submitButton;
	/**
	 * @uml.property  name="zipcode"
	 */
	String zipcode="";
	
	
	public void onCreate(Bundle savedInstanceState)
	{
		super.onCreate(savedInstanceState);
		setContentView(R.layout.zip_layout);
		text = (EditText) findViewById(R.id.editText1);

		Log.v("EditText", zipcode);
		submitButton =(Button)findViewById(R.id.button3);
	

	}
	


	//when submit button is clicked
	public void myClickHandler(View view)
	{
		zipcode=text.getText().toString();
		if (zipcode.length() !=5)
		{
			Toast.makeText(this, "Please enter a valid Zip Code",Toast.LENGTH_LONG).show();
		}
		else 
		{
			Bundle bundle = new Bundle();

			bundle.putString("zipvalue", zipcode);
			Intent activity3Intent = new Intent(this, AQIByZipCode.class);
			activity3Intent.putExtras(bundle);
			
			
			View view2 = ZipActivity.group.getLocalActivityManager()
					.startActivity("AQIByZipCode", activity3Intent
							.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP))
							.getDecorView();

					ZipActivity.group.replaceView(view2);
			
			//replaceContentView("AQIByZipCode", activity3Intent);
//			View v = getLocalActivityManager().startActivity("AQIByZipCode", activity3Intent).getDecorView(); 
//			
//			setContentView(v);
			text.setText("");



		}


	}
	
	
	/*@Override
	public boolean onKeyDown(int keyCode, KeyEvent event) {
		System.out.println("MAIN PRESSED");
		return super.onKeyDown(keyCode, event);
	}
*/

}
